{template '_header'}

<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}案例{if !empty($item['id'])}({$item['title']}){/if}</span>
</div>

<div class="page-content">
 <div class="page-sub-toolbar">
    <span class="">
        {ifp 'system.site.case.add'}
            <a class="btn btn-primary btn-sm" href="{php echo webUrl('system/site/case/add')}">添加新案例</a>
		{/if}
    </span>
 </div>
    <form {ife 'system.site.case' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$item['id']}" />
                <div class="form-group">
                    <label class="col-lg control-label">排序</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'system.site.case' $item}
                                <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                                <span class='help-block'>数字越大，排名越靠前</span>
                        {else}
                            <div class='form-control-static'>{$item['displayorder']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg control-label must">案例分类</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'system.site.case' $item}
                        <select name='cate' id='cate' class='form-control select2'>
                            <option value=''></option>
                            {loop $category $k $c}
                            <option value='{$k}' {if $item['cate']==$k}selected{/if}>{$c['name']}</option>
                            {/loop}
                        </select>
                        {else}
                        <div class='form-control-static'>{if empty($item['cate'])}暂时无分类{else} {$category[$item['cate']]['name']}{/if}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg control-label must">案例名称</label>
                    <div class="col-sm-9 col-xs-12 ">
                        {ife 'system.site.case' $item}
                        <input type="text" id='title' name="title" class="form-control" value="{$item['title']}" data-rule-required="true" />
                        {else}
                        <div class='form-control-static'>{$item['title']}</div>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg control-label">案例图片</label>
                    <div class="col-sm-9 col-xs-12">
                         {ife 'system.site.case' $item}
                        {php echo tpl_form_field_image2('thumb', $item['thumb'])}
                        <span class='help-block'>建议尺寸:270 * 470 , 请将所有案例图片尺寸保持一致</span>
                        {else}
                            {if !empty($item['thumb'])}
                                  <a href='{php echo tomedia($item['thumb'])}' target='_blank'>
                            <img src="{php echo tomedia($item['thumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                                  </a>
                            {/if}
                        {/if}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg control-label">案例二维码</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'system.site.case' $item}
                        {php echo tpl_form_field_image2('qr', $item['qr'])}
                        <span class='help-block'>建议尺寸:140 * 140 </span>
                        {else}
                        {if !empty($item['thumb'])}
                        <a href='{php echo tomedia($item['thumb'])}' target='_blank'>
                        <img src="{php echo tomedia($item['thumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                        </a>
                        {/if}
                        {/if}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg control-label">案例描述</label>
                    <div class="col-sm-9 col-xs-12 ">
                        {ife 'system.site.case' $item}
                        <textarea id="" cols="30" rows="5" name="description" class="form-control" value="">{$item['description']}</textarea>
                        {else}
                        <div class='form-control-static'>{$item['description']}</div>
                        {/if}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg control-label">状态</label>
                    <div class="col-sm-9 col-xs-12">
                            {ife 'system.site.case' $item}
                        <label class='radio-inline'>
                            <input type='radio' name='status' value='1' {if $item['status']==1}checked{/if} /> 显示
                        </label>
                        <label class='radio-inline'>
                            <input type='radio' name='status' value='0' {if $item['status']==0}checked{/if} /> 隐藏
                        </label>
                     {else}
                            <div class='form-control-static'>{if empty($item['status'])}隐藏{else}显示{/if}</div>
                        {/if}
                    </div>
                </div>
            
                <div class="form-group">
                        <label class="col-lg control-label"></label>
                        <div class="col-sm-9 col-xs-12">
                               {ife 'system.site.case' $item}
                                <input type="submit" value="提交" class="btn btn-primary"  />
                            {/if}
                           <input type="button" name="back" onclick='history.back()' {ifp 'system.site.case.add|system.site.case.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
                        </div>
                </div>
    </form>
</div>

<script language='javascript'>
    $('form').submit(function(){
        if ($("#cate").isEmpty()) {
            $('form').attr('stop',1);
            tip.msgbox.err("请填写案例分类!");
            return false;
        }
        $('form').removeAttr('stop');
        return true;
    });
</script>

{template '_footer'}